//
//  ZCInvolvedDetailsModelChildComments.m
//
//  Created by   on 16/3/28
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "ZCInvolvedDetailsModelChildComments.h"


NSString *const kZCInvolvedDetailsModelChildCommentsId = @"id";
NSString *const kZCInvolvedDetailsModelChildCommentsMid = @"mid";
NSString *const kZCInvolvedDetailsModelChildCommentsCommentCount = @"comment_count";
NSString *const kZCInvolvedDetailsModelChildCommentsIshidden = @"ishidden";
NSString *const kZCInvolvedDetailsModelChildCommentsCtype = @"ctype";
NSString *const kZCInvolvedDetailsModelChildCommentsAvatar = @"avatar";
NSString *const kZCInvolvedDetailsModelChildCommentsCtime = @"ctime";
NSString *const kZCInvolvedDetailsModelChildCommentsLikecount = @"likecount";
NSString *const kZCInvolvedDetailsModelChildCommentsUsername = @"username";
NSString *const kZCInvolvedDetailsModelChildCommentsForId = @"for_id";
NSString *const kZCInvolvedDetailsModelChildCommentsPid = @"pid";
NSString *const kZCInvolvedDetailsModelChildCommentsContent = @"content";


@interface ZCInvolvedDetailsModelChildComments ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ZCInvolvedDetailsModelChildComments

@synthesize childCommentsIdentifier = _childCommentsIdentifier;
@synthesize mid = _mid;
@synthesize commentCount = _commentCount;
@synthesize ishidden = _ishidden;
@synthesize ctype = _ctype;
@synthesize avatar = _avatar;
@synthesize ctime = _ctime;
@synthesize likecount = _likecount;
@synthesize username = _username;
@synthesize forId = _forId;
@synthesize pid = _pid;
@synthesize content = _content;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.childCommentsIdentifier = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsId fromDictionary:dict];
            self.mid = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsMid fromDictionary:dict];
            self.commentCount = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsCommentCount fromDictionary:dict];
            self.ishidden = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsIshidden fromDictionary:dict];
            self.ctype = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsCtype fromDictionary:dict];
            self.avatar = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsAvatar fromDictionary:dict];
            self.ctime = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsCtime fromDictionary:dict];
            self.likecount = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsLikecount fromDictionary:dict];
            self.username = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsUsername fromDictionary:dict];
            self.forId = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsForId fromDictionary:dict];
            self.pid = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsPid fromDictionary:dict];
            self.content = [self objectOrNilForKey:kZCInvolvedDetailsModelChildCommentsContent fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.childCommentsIdentifier forKey:kZCInvolvedDetailsModelChildCommentsId];
    [mutableDict setValue:self.mid forKey:kZCInvolvedDetailsModelChildCommentsMid];
    [mutableDict setValue:self.commentCount forKey:kZCInvolvedDetailsModelChildCommentsCommentCount];
    [mutableDict setValue:self.ishidden forKey:kZCInvolvedDetailsModelChildCommentsIshidden];
    [mutableDict setValue:self.ctype forKey:kZCInvolvedDetailsModelChildCommentsCtype];
    [mutableDict setValue:self.avatar forKey:kZCInvolvedDetailsModelChildCommentsAvatar];
    [mutableDict setValue:self.ctime forKey:kZCInvolvedDetailsModelChildCommentsCtime];
    [mutableDict setValue:self.likecount forKey:kZCInvolvedDetailsModelChildCommentsLikecount];
    [mutableDict setValue:self.username forKey:kZCInvolvedDetailsModelChildCommentsUsername];
    [mutableDict setValue:self.forId forKey:kZCInvolvedDetailsModelChildCommentsForId];
    [mutableDict setValue:self.pid forKey:kZCInvolvedDetailsModelChildCommentsPid];
    [mutableDict setValue:self.content forKey:kZCInvolvedDetailsModelChildCommentsContent];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.childCommentsIdentifier = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsId];
    self.mid = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsMid];
    self.commentCount = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsCommentCount];
    self.ishidden = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsIshidden];
    self.ctype = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsCtype];
    self.avatar = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsAvatar];
    self.ctime = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsCtime];
    self.likecount = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsLikecount];
    self.username = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsUsername];
    self.forId = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsForId];
    self.pid = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsPid];
    self.content = [aDecoder decodeObjectForKey:kZCInvolvedDetailsModelChildCommentsContent];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_childCommentsIdentifier forKey:kZCInvolvedDetailsModelChildCommentsId];
    [aCoder encodeObject:_mid forKey:kZCInvolvedDetailsModelChildCommentsMid];
    [aCoder encodeObject:_commentCount forKey:kZCInvolvedDetailsModelChildCommentsCommentCount];
    [aCoder encodeObject:_ishidden forKey:kZCInvolvedDetailsModelChildCommentsIshidden];
    [aCoder encodeObject:_ctype forKey:kZCInvolvedDetailsModelChildCommentsCtype];
    [aCoder encodeObject:_avatar forKey:kZCInvolvedDetailsModelChildCommentsAvatar];
    [aCoder encodeObject:_ctime forKey:kZCInvolvedDetailsModelChildCommentsCtime];
    [aCoder encodeObject:_likecount forKey:kZCInvolvedDetailsModelChildCommentsLikecount];
    [aCoder encodeObject:_username forKey:kZCInvolvedDetailsModelChildCommentsUsername];
    [aCoder encodeObject:_forId forKey:kZCInvolvedDetailsModelChildCommentsForId];
    [aCoder encodeObject:_pid forKey:kZCInvolvedDetailsModelChildCommentsPid];
    [aCoder encodeObject:_content forKey:kZCInvolvedDetailsModelChildCommentsContent];
}

- (id)copyWithZone:(NSZone *)zone
{
    ZCInvolvedDetailsModelChildComments *copy = [[ZCInvolvedDetailsModelChildComments alloc] init];
    
    if (copy) {

        copy.childCommentsIdentifier = [self.childCommentsIdentifier copyWithZone:zone];
        copy.mid = [self.mid copyWithZone:zone];
        copy.commentCount = [self.commentCount copyWithZone:zone];
        copy.ishidden = [self.ishidden copyWithZone:zone];
        copy.ctype = [self.ctype copyWithZone:zone];
        copy.avatar = [self.avatar copyWithZone:zone];
        copy.ctime = [self.ctime copyWithZone:zone];
        copy.likecount = [self.likecount copyWithZone:zone];
        copy.username = [self.username copyWithZone:zone];
        copy.forId = [self.forId copyWithZone:zone];
        copy.pid = [self.pid copyWithZone:zone];
        copy.content = [self.content copyWithZone:zone];
    }
    
    return copy;
}


@end
